home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0150_Rain Dance Mimic.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  2KB  |  73 lines

  1. {
  2. movement mimics dancing rain? [closest analogy I can think of]
  3. }
  4. uses crt;
  5. const Balls = 1900;  {increment if too fast: decrement if too slow}
  6. type movement= record
  7.      x,   y : integer;  { position }
  8.     dx,  dy : integer;  { velocity }
  9.    ddx, ddy : integer;  { acceleration }
  10.    color    : integer;
  11.    MaxYValue: integer;
  12.         END;
  13. VAR ch : char;
  14.     I  : integer;
  15.  Ball: array[1..BAlls] of movement;
  16. Procedure VideoMode ( Mode : Byte );
  17.     Begin { VideoMode }
  18.       Asm
  19.         Mov  AH,00
  20.         Mov  AL,Mode
  21.         Int  10h
  22.       End;
  23.     End;  { VideoMode }
  24. procedure PutDot(x,y,color:integer);
  25.   begin
  26.     Mem[$A000{VGA_Segment}:(y*320)+x] := color;
  27.   end;
  28.  
  29. BEGIN
  30. videoMODE($13);
  31. randomize;
  32. {init all balls}
  33. for i:=1 to BAlls do BEGIN
  34. With ball[i] do BEGIN
  35. ddx := 0;             { no horizontal acceleration }
  36. ddy := 1;             { constant vertical acceleration }
  37.  dx := Random(2)-1;   { push it left of right to start}
  38.  if dx=0 then dx:=1;  { all balls will have a horizontal movement}
  39.  dy:=0;               { the object is initially at rest }
  40.   x := I div ((i div 320)+1); { initial coordinates, as }
  41.   y := i mod 130+random(3); {   you specified }
  42.   color:=random(I mod 255);  {Each Balls color}
  43.   MaxYValue:=Y+1;
  44. END; {with}
  45. END; {for do loop}
  46. WHILE not(keypressed) do begin
  47.  FOR i:=1 to Balls do BEGIN
  48.   With ball[i] do BEGIN
  49.   putdot(x, y, 0);    { blank out the pixel drawn on the last iteration }
  50.   dx := dx + ddx;     { updating velocity }
  51.   dy := dy + ddy;
  52.   x  :=  x +  dx;     { updating position }
  53.   y  :=  y +  dy;
  54.   IF x< 1 then begin      {hits left of screen}
  55.      X:=1;
  56.      dx:=dx*-1;
  57.   End;
  58.   IF x > 319 then begin   {hits right of screen}
  59.      x :=319;
  60.      dx:=-dx;
  61.   END;
  62.   IF y > 190 then begin   { BOUNCE! }
  63.     y := 190;
  64.     dy := -dy;
  65.   End;
  66.   putdot(x, y, color);  { draw the pixel at the new position }
  67.   END; {WITH}
  68.  END; {for do loop}
  69. End; {KEYPRESS}
  70. videoMODe($3);
  71. end. {PROGRAM}
  72.  
  73.